package hc.bre.policy

import hc.bre.ComponentConfig
import hc.bre.cmn.RuleScriptBuilder
import hc.bre.cmn.RuleDefinition

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class CheckDefinition  extends RuleDefinition{
	public static final ComponentConfig _config ;
	static {
		_config = new ComponentConfig();
		_config.rtype = 'rule:policy:check';
		_config.rname = '政策检查集';
		_config.builderClass = CheckBuilder;
		_config.resultStruct = new CheckResultStruct();
		_config.objectpage = '/rule/policy/checkeditor.htm?rpath=${rpath}';
		_config.description = '';
	}


	//category id  to yes/no
	HashMap<Integer, Boolean> categoryHitToStop=[:];
	
	//reason id to category id.
	HashMap<Integer, Integer> reasonBelongsTo=[:];

	//TODO will to support
	def mergeSettings

	@Override
	public CheckDefinition load(Map map) {
		super.load(map);


		Map temp = map['categoryHitToStop'] as Map;
		temp?.each {k,v ->
			categoryHitToStop.put(Integer.parseInt(k.toString()),v as Boolean);
		};

		temp = map['reasonBelongsTo'] as Map;
		temp?.each { k, v ->
			if(v)
				reasonBelongsTo.put(Integer.parseInt(k.toString()),v as Integer);
		};

		mergeSettings = map['mergeSettings']

		return this;
	}

	
//	@Override
//	public <T extends RuleScriptBuilder> Class<T> scriptBuilderClass() {
//		return CheckBuilder.class;
//	}
}
